<?php
/**
 * Magento Enterprise Edition
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Magento Enterprise Edition End User License Agreement
 * that is bundled with this package in the file LICENSE_EE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.magento.com/license/enterprise-edition
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magento.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magento.com for more information.
 *
 * @category    design
 * @package     default_default
 * @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
 * @license http://www.magento.com/license/enterprise-edition
 */
?>
<?php $websites = $this->getWebsites(); ?>
<?php if ($websites): ?>
<p class="switcher"><label for="website_switcher"><?php echo $this->__('Choose Website:') ?></label>
<?php echo $this->getHintHtml() ?>
<select name="website_switcher" id="website_switcher" onchange="return switchWebsite(this);">
<?php if ($this->hasDefaultOption()): ?>
    <option value=""><?php echo $this->getDefaultStoreName() ?></option>
<?php endif; ?>
    <?php foreach ($websites as $website): ?>
        <option value="<?php echo $website->getId() ?>"<?php if ($this->getStoreId() == $website->getId()): ?> selected="selected"<?php endif; ?>><?php echo $website->getName() ?></option>
    <?php endforeach; ?>
</select>
</p>
<script type="text/javascript">
    function switchWebsite(obj){
        var storeParam = obj.value ? 'website/'+obj.value + '/' : '';
        if(obj.switchParams){
            storeParam+= obj.switchParams;
        }
    <?php if($this->getUseConfirm()): ?>
        if(confirm('<?php echo Mage::helper('core')->jsQuoteEscape($this->__('Please confirm site switching. All data that hasn\'t been saved will be lost.')) ?>')){
            setLocation('<?php echo $this->getSwitchUrl() ?>'+storeParam);
            return true;
        }
        else {
            obj.value = '<?php echo $this->getStoreId() ?>';
        }
        return false;
    <?php else: ?>
        setLocation('<?php echo $this->getSwitchUrl() ?>'+storeParam);
    <?php endif; ?>
    }
</script>
<?php endif; ?>
